package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Setter
@Getter
@JsonIgnoreProperties(value = {"handler","hibernateLazyInitializer","fieldHandler"})
public class Strategy extends BaseDomain {
    public static final int STATE_NORMAL = 1;
    public static final int STATE_COMMEND = 2;
    public static final int STATE_DISABLE = 3;


    private Region place; //地点

    private String title;   //标题

    private String subTitle; //子标题

    private String coverUrl; //封面

    private Integer state=1;  //状态
    //一对多
    private List<Travel> travels=new ArrayList<>();

    public String getStateName() {
        String stateName="未知";
        if (state == STATE_NORMAL) {
            stateName="正常";
        } else if (state == STATE_COMMEND) {
            stateName="推荐";
        } else if (state == STATE_DISABLE) {
            stateName="禁用";
        }
        return stateName;
    }

    public String getJsonString(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",getId());
        map.put("title",title);
        map.put("subTitle",subTitle);
        map.put("coverUrl",coverUrl);
        if (place != null) {
        map.put("placeId",place.getId());
        }
        if (state != null) {
        map.put("state",state);
        }


        return JSONUtil.toJSONString(map);
    }


}